package dk.aau.medialogy.y2013.p4;

import processing.core.PApplet;
import processing.core.PImage;
import controlP5.ControlFont;
import controlP5.ControlP5;
import controlP5.MultiList;
import controlP5.MultiListButton;
import controlP5.RadioButton;
import controlP5.Slider2D;
import controlP5.Textlabel;


public class Button extends PApplet
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static MultiList l;
	static MultiList l2;
	static RadioButton r;
	Slider2D s;
	static Textlabel ChorusText , distortionText, echoText, equilizerText, phasorText, tremoloText, vibratoText, wahwahText;
	
	
	// slider button names are stored in Main
	
	public static void Setup(PImage[] imgs, ControlFont font)
	{
		
		SystemManager.cp5.addButton("chorus_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR , SystemManager.BUTTON_SIZE ).setImage(imgs[0])
				.updateSize();

		SystemManager.cp5.addButton("distortion_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 2 * SystemManager.BUTTON_SIZE).setImage(imgs[1])
				.updateSize();

		SystemManager.cp5.addButton("echo_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 3 * SystemManager.BUTTON_SIZE).setImage(imgs[2])
				.updateSize();

		SystemManager.cp5.addButton("equilizer_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 4 * SystemManager.BUTTON_SIZE).setImage(imgs[3])
				.updateSize();

		SystemManager.cp5.addButton("phasor_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 5 * SystemManager.BUTTON_SIZE).setImage(imgs[4])
				.updateSize();

		SystemManager.cp5.addButton("tremolo_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 6 * SystemManager.BUTTON_SIZE).setImage(imgs[5])
				.updateSize();

		SystemManager.cp5.addButton("vibrato_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 7 * SystemManager.BUTTON_SIZE).setImage(imgs[6])
				.updateSize();

		SystemManager.cp5.addButton("wahwah_Button").setValue(1)
				.setPosition(SystemManager.ADDED_BAR, 8 * SystemManager.BUTTON_SIZE).setImage(imgs[7])
				.updateSize();

		SystemManager.cp5.addSlider("OscilFrequency")
				.setPosition(SystemManager.WINDOW_WIDTH / 2 - 100, SystemManager.HEIGHT / 2 - SystemManager.MIDT_BUTTON_SIZE / 2 + 5)
				.setSize(200, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(1, 20000)
				.setCaptionLabel("Oscilator Hz").setLabelVisible(true).setValue(1).hide();
		
		
		// Effect buttons 
		SystemManager.cp5.addSlider("Chorus1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Delay").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("Chorus2")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 2 * SystemManager.BUTTON_SIZE + 20)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(-64, 63)
		.setCaptionLabel("Feedback").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("Chorus3")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 3 * SystemManager.BUTTON_SIZE + 30)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Rate").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("Chorus4")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 4 * SystemManager.BUTTON_SIZE + 40)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Mod amount").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("distortion1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Damage control").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("distortion2")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 2 * SystemManager.BUTTON_SIZE + 20)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("P1").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("distortion3")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 3 * SystemManager.BUTTON_SIZE + 30)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("P2").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("echo1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(10, 2000)
		.setCaptionLabel("Echo time ms").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("echo2")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 2 * SystemManager.BUTTON_SIZE + 20)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Diffusion").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("echo3")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 3 * SystemManager.BUTTON_SIZE + 30)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Decay").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("echo4")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 4 * SystemManager.BUTTON_SIZE + 40)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Dry-Wet").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("equilizer1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Band pass").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("equilizer2")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 2 * SystemManager.BUTTON_SIZE + 20)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Band pass").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("equilizer3")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 3 * SystemManager.BUTTON_SIZE + 30)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Bandpass").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("equilizer4")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 4 * SystemManager.BUTTON_SIZE + 40)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Bandpass").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("phasor1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Frequency").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("phasor2")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 2 * SystemManager.BUTTON_SIZE + 20)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Split").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("phasor3")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 3 * SystemManager.BUTTON_SIZE + 30)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Width").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("phasor4")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 4 * SystemManager.BUTTON_SIZE + 40)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Rate").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("phasor5")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 5 * SystemManager.BUTTON_SIZE + 50)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Feedback").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("tremolo1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Rate").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
				
		SystemManager.cp5.addSlider("vibrato1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Rate").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
				
		SystemManager.cp5.addSlider("wahwah1")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, SystemManager.BUTTON_SIZE + 10)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Frequency").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("wahwah2")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 2 * SystemManager.BUTTON_SIZE + 20)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Resolution").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		SystemManager.cp5.addSlider("wahwah3")
		.setPosition(SystemManager.WINDOW_WIDTH + 5, 3 * SystemManager.BUTTON_SIZE + 30)
		.setSize(220, SystemManager.MIDT_BUTTON_SIZE - 10).setRange(0, 127)
		.setCaptionLabel("Rate").setLabelVisible(true).setVisible(false)
		.getCaptionLabel().align(ControlP5.CENTER, ControlP5.TOP_OUTSIDE);
		
		
		// Labels for the different effects
		ChorusText = SystemManager.cp5.addTextlabel("choruslabel")
                .setText("Chorus")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;		

		distortionText = SystemManager.cp5.addTextlabel("distortionlabel")
                .setText("Distortion")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;		
		
		echoText = SystemManager.cp5.addTextlabel("echolabel")
                .setText("Echo")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;		
		
		equilizerText = SystemManager.cp5.addTextlabel("equilizerlabel")
                .setText("Equalizer")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;		
		
		phasorText = SystemManager.cp5.addTextlabel("phasorlabel")
                .setText("Phasor")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;		
		
		vibratoText = SystemManager.cp5.addTextlabel("vibratolabel")
                .setText("Vibrato")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;		

		wahwahText = SystemManager.cp5.addTextlabel("wahwahlabel")
                .setText("Wahwah")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;
		
		tremoloText = SystemManager.cp5.addTextlabel("tremololabel")
                .setText("Tremolo")
                .setPosition(SystemManager.WINDOW_WIDTH + 20,0)
                .hide()
                .setFont(font)
                ;
		
//		// Adds two mulitilist buttons for the midt bare for changeing the windows and ocilator
//		l2 = SystemManager.cp5.addMultiList("Input signal control", SystemManager.WINDOW_WIDTH / 2
//				- SystemManager.MIDT_BUTTON_SIZE * 2 - 103, SystemManager.HEIGHT / 2 - SystemManager.MIDT_BUTTON_SIZE / 2
//				+ 10, SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE - 20);
//
//		MultiListButton c;
//		c = l2.add("Input Signal", 1);
//
//		c.add("sLevel11", 11).setCaptionLabel("Oscillator")
//				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		c.add("sLevel12", 12).setCaptionLabel("Sawtooth")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
//		c.add("sLevel13", 13).setCaptionLabel("Import sound file")
//				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		c.add("sLevel14", 14).setCaptionLabel("Microphone")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
//
//		l = SystemManager.cp5.addMultiList("Screen", 0, SystemManager.HEIGHT / 2 - SystemManager.MIDT_BUTTON_SIZE / 2,
//				SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
//
//		MultiListButton b;
//		b = l.add("Time domain", 1);
////
////		// add items to a sublist of button "level1"
////		b.add("level11", 11).setCaptionLabel("Frequency domain modified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		b.add("level12", 12).setCaptionLabel("Frequency domain umodified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		b.add("level13", 13).setCaptionLabel("Time domain modified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		b.add("level14", 14).setCaptionLabel("Time domain umodified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
//
//		b = l.add("Frequency domain", 2);
////		b.add("level21", 21).setCaptionLabel("Frequency domain modified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		b.add("level22", 22).setCaptionLabel("Frequency domain umodified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		b.add("level23", 23).setCaptionLabel("Time domain modified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);
////		b.add("level24", 24).setCaptionLabel("Time domain umodified")
////				.setSize(SystemManager.MIDT_BUTTON_SIZE * 2, SystemManager.MIDT_BUTTON_SIZE / 2 - 1);

		
		
		r = SystemManager.cp5.addRadioButton("radioButton")
				.setPosition(0,
						SystemManager.HEIGHT / 2 - SystemManager.MIDT_BUTTON_SIZE / 2)
				.setSize(SystemManager.MIDT_BUTTON_SIZE, SystemManager.MIDT_BUTTON_SIZE).setItemsPerRow(5)
				.setSpacingColumn(50).addItem("SineWave", 1).addItem("Music", 2);
	}
	

	public void draw()
	{
		
	}
}
